<?php
/**
 * @ClassName: Managemenus
 * @Description: TODO
 * @author: gydtrade
 * @Date: 2025-09-10 13:38
 * @Version: V1.0.0
 */

namespace app\api\controller;

use app\common\model;
use think\Controller;

class Managemenus extends Controller
{
    protected function initialize()
    {
    }

    function getMenu()
    {
        $menu_type = input('menu_type');
        $role_type = input('role', 4);
        $merchant_type = input('merchant_type');

        $where = [
            'status' => 1,
            'menu_type' => $menu_type,
            'merchant_type' => $merchant_type,
            'role_type' => $role_type,
        ];

        $list = model\ManageMenus::where($where)->order('sort')->select()->toArray();

        foreach ($list as &$item) {
            if ($item['icon'] && substr($item['icon'], 0, 1) === "/") {
                $item['icon'] = replace_url($item['icon']);
            }
            if ($item['image'] && substr($item['image'], 0, 1) === "/") {
                $item['image'] = replace_url($item['image']);
            }
        }

        return json([
            'code' => 1,
            'msg' => '获取成功',
            'data' => $list,
        ]);
    }

}